<?php
function entityList($entity, $query = array())
{
    $query['conditions']['created']['$lte'] = time();
    $di = \Phalcon\Di::getDefault();
    $data = $di->getShared('entityManager')->find($entity,$query);
    if($data){
        return $data;
    }
    return [];
}

//定义函数
function entityFind($entity, $query = array())
{
    $di = \Phalcon\Di::getDefault();
    $entityModel = $di->getShared('entityManager')->find($entity, $query);
    return $entityModel;
}

function entity_render($entity, $data)
{
    $output = array(
        '#templates' => array(
            'entity',
            'entity' . ucfirst($entity)
        ),
        'data' => $data
    );
    if (isset($data->contentModel)) {
        $output['#templates'][] = 'entity' . ucfirst($entity) . ucfirst($data->contentModel);
    }
    return $output;
}